import useUploadOss from "../../hook/useUploadOss.ts";
import { Upload } from "antd";

export default ({ children, value = [],onChange, ...rest }: any) => {
  const { upload } = useUploadOss();
  const handlOnChange = (info: any) => {
    onChange?.(info?.fileList ?? [])
  }
  return (
    <Upload
      fileList={value}
      onChange={handlOnChange}
      {...rest}
      customRequest={(options) => {
        // Custom request logic here
        upload({
          file: options.file as Blob,
          //   filename: options.filename as string,
          //   directory:"files/1301/admin_upload/",
          onProgress: options.onProgress,
          onSuccess: options.onSuccess,
          onError: options.onError,
        });
      }}
    >
      {children}
    </Upload>
  );
};
